package com.gjy.nwpufindseats.util;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo.State;
import android.widget.Toast;

public class NetInfo {
	
		public boolean isNetConnect(Context context){
	        boolean success = false;
			//获得网络连接服务
			ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
			// State state = connManager.getActiveNetworkInfo().getState();
			State state = connManager.getNetworkInfo(
			        ConnectivityManager.TYPE_WIFI).getState(); // 获取网络连接状态
			if (State.CONNECTED == state) { // 判断是否正在使用WIFI网络
			    success = true;
			}
			
			state = connManager.getNetworkInfo(
			        ConnectivityManager.TYPE_MOBILE).getState(); // 获取网络连接状态
			if (State.CONNECTED == state) { // 判断是否正在使用GPRS网络
			    success = true;
			}
			if(!success)
			{
				Toast.makeText(context, "请检查您的网络连接", Toast.LENGTH_SHORT).show();
			}
			return success;
}

}
